package test.teacher.common.filter;

import test.teacher.Teacher;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @date 2018/5/18  17:30
 */
//@WebFilter(filterName = "SessionTimeOutFilter")
public class SessionTimeOutFilter implements Filter {
    public void destroy() {
        System.out.println("filter2 关闭了");
    }

    public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
        HttpServletRequest servletRequest1 = (HttpServletRequest) req;
        HttpServletResponse servletResponse1 = (HttpServletResponse) resp;
        System.out.println("filter2 过滤中");
        chain.doFilter(req,resp);
        //if (servletRequest1.getRequestURI().contains("login") || servletRequest1.getRequestURI().contains("index")) {
            //chain.doFilter(servletRequest1, servletResponse1);
        /*}
        else {
            Teacher teacher = (Teacher) servletRequest1.getSession().getAttribute("userInfo");
            if (teacher == null) {
                servletRequest1.getRequestDispatcher("index.jsp").forward(servletRequest1, servletResponse1);
            } else {
                servletRequest1.getRequestDispatcher("WEB-INF/studentList.jsp").forward(servletRequest1,servletResponse1);
            }
        }*/
    }

    public void init(FilterConfig config) throws ServletException {
        System.out.println("filter2启动了");
    }

}
